package com.leyou.item.controller;

import com.leyou.item.entity.Sku;
import com.leyou.item.service.SkuService;
import com.leyou.item.vo.PageResult;
import com.leyou.item.vo.SpuVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author linzx
 * @date 2020/3/25
 */
@RestController
@RequestMapping("sku")
public class SkuController {
    @Autowired
    private SkuService skuService;

    /**
     * 根据spuId查询sku
     * @param spuId
     * @return
     */
    @GetMapping("list")
    public ResponseEntity<List<Sku>> findSkuBySpuId(@RequestParam("id") Long spuId) {
        return ResponseEntity.ok(skuService.findSkuWithStockBySpuId(spuId)) ;
    }




}
